<template>
  <div>
    <public-modal
      width="880px"
      :footer="false"
      :title="title"
      :publicVisible="publicVisible"
      @handleOk="handleOk"
      @cancel="cancel"
    >
      <div slot="content" class="form-wrapper right-content">
        <div class="common-title">
          <div class="icon"></div>
          <div class="content">基础信息</div>
        </div>
        <div class="content-wrapper">
          <div class="flex">
            <div class="info-wrap f1">
              <div class="label common-lable">人员类型</div>
              <div class="value common-value">{{ wbHelpBean.helpPersonType || '暂无' }}</div>
            </div>
            <div class="info-wrap f1">
              <div class="label common-lable">身份证号</div>
              <div class="value common-value">{{ wbHelpBean.helpIdCard || '暂无' }}</div>
            </div>
          </div>
          <div class="flex">
            <div class="info-wrap f1">
              <div class="label common-lable">人员姓名</div>
              <div class="value common-value">{{ wbHelpBean.helpName || '暂无' }}</div>
            </div>
            <div class="info-wrap f1">
              <div class="label common-lable">联系电话</div>
              <div class="value common-value">
                {{ wbHelpBean.helpPhone || '暂无' }}
              </div>
            </div>
          </div>

          <div class="flex">
            <div class="info-wrap f1">
              <div class="label common-lable">居住地址/所属单位</div>
              <div class="value common-value">{{ wbHelpBean.orgName || '暂无' }}</div>
            </div>
          </div>
        </div>

        <div class="common-title">
          <div class="icon"></div>
          <div class="content">绑定患者</div>
        </div>

        <a-table
          rowKey="id"
          class="wearing-table"
          :columns="bingColumns"
          :dataSource="wbHelpMentalPatientList"
          :pagination="false"
        >
          <template slot="action" slot-scope="records">
            <span class="operation deatil-color" @click="handleChange(records)">更换</span>
          </template>
        </a-table>

        <div class="common-title">
          <div class="icon"></div>
          <div class="content">操作信息</div>
        </div>
        <div class="content-wrapper">
          <div class="flex">
            <div class="info-wrap f1">
              <div class="label common-lable">新增时间</div>
              <div class="value common-value">{{ wbHelpBean.createTime || '暂无' }}</div>
            </div>
            <div class="info-wrap f1">
              <div class="label common-lable">操作人员</div>
              <div class="value common-value">{{ wbHelpBean.createBy }}</div>
            </div>
          </div>
          <div class="flex">
            <div class="info-wrap f1">
              <div class="label common-lable">更新时间</div>
              <div class="value common-value">{{ wbHelpBean.updateTime || '暂无' }}</div>
            </div>
            <div class="info-wrap f1">
              <div class="label common-lable">操作人员</div>
              <div class="value common-value">{{ wbHelpBean.updateBy }}</div>
            </div>
          </div>
        </div>
      </div>
      <div slot="footer"></div>
    </public-modal>
  </div>
</template>

<script>
import { uploadFile } from '@/api/api'
import { checkIDCard } from '@/utils/validate.js'
import publicModal from '@/components/publicModal'
import { putAction, postAction } from '@/api/manage'
import { isMobile } from '@/utils/validate'
import { helpinfoHelpInfoDetails } from '../../../../api/api'

export default {
  name: 'addPoliceModal',
  components: { publicModal },
  data() {
    return {
      title: '详情',
      record: {},
      status: 0,
      publicVisible: false,
      imageUrl: [],
      fileList: [],
      showUploadList: { showPreviewIcon: false },
      form: {},
      rules: {},
      detail: {},
      bingColumns: [
        {
          title: '序号',
          align: 'center',
          width: 80,
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },
        {
          title: '精神障碍等级',
          dataIndex: 'patientLevel',
          ellipsis: true,
          align: 'center',
          width: 130,
          customRender: (t) => {
            return (
              <a-tooltip placement="top">
                <template slot="title">
                  <span>{t}</span>
                </template>
                <div class="ant-table-row-cell-ellipsis">{t}</div>
              </a-tooltip>
            )
          },
        },
        {
          title: '姓名',
          dataIndex: 'name',
          ellipsis: true,
          align: 'center',
          width: 100,
          customRender: (t) => {
            return (
              <a-tooltip placement="top">
                <template slot="title">
                  <span>{t}</span>
                </template>
                <div class="ant-table-row-cell-ellipsis">{t}</div>
              </a-tooltip>
            )
          },
        },
        {
          title: '身份证号',
          dataIndex: 'idCard',
          ellipsis: true,
          align: 'center',
          customRender: (t) => {
            return (
              <a-tooltip placement="top">
                <template slot="title">
                  <span>{t}</span>
                </template>
                <div class="ant-table-row-cell-ellipsis">{t}</div>
              </a-tooltip>
            )
          },
        },
        {
          title: '操作人员',
          dataIndex: 'createBy',
          ellipsis: true,
          width: 100,

          align: 'center',
          customRender: (t) => {
            return (
              <a-tooltip placement="top">
                <template slot="title">
                  <span>{t}</span>
                </template>
                <div class="ant-table-row-cell-ellipsis">{t}</div>
              </a-tooltip>
            )
          },
        },
        {
          title: '操作时间',
          dataIndex: 'createTime',
          ellipsis: true,
          align: 'center',
          customRender: (t) => {
            return (
              <a-tooltip placement="top">
                <template slot="title">
                  <span>{t}</span>
                </template>
                <div class="ant-table-row-cell-ellipsis">{t}</div>
              </a-tooltip>
            )
          },
        },
      ],
      bindDataList: [],
      wbHelpBean: {},
      wbHelpMentalPatientList: [],
      actionType: 'add',
    }
  },
  mounted() {},
  methods: {
    show(record, actionType = 'add') {
      this.record = record
      this.publicVisible = true
      this.actionType = actionType
      if (actionType == 'edit') {
        this.form = { ...record }
      }
      helpinfoHelpInfoDetails({
        id: record.id,
      }).then((res) => {
        const { wbHelpBean, wbHelpMentalPatientList } = res.result
        this.wbHelpBean = wbHelpBean
        this.wbHelpMentalPatientList = wbHelpMentalPatientList
      })
    },
    remove(file) {
      let uid = file.uid
      let index = this.fileList.findIndex((v) => {
        return v.uid == uid
      })

      this.fileList.splice(index, 1)
      this.imageUrl.splice(index, 1)
    },
    async customRequest(info) {
      let file = info.file
      const formData = new FormData()
      formData.append('file', file)
      if (this.status == 0) formData.append('type', 2)
      else if (this.status == 1) formData.append('type', 63)
      else if (this.status == 2) formData.append('type', 64)
      let res = await uploadFile(formData)
      if (res.code == 200) {
        this.imageUrl.push(res.result.halfPath)
      }
    },
    uploadChange({ file, fileList }) {
      file.status = 'done'
      this.fileList = fileList
    },

    handleOk() {},

    cancel() {
      this.publicVisible = false
      this.fileList = []
      this.imageUrl = []
      this.form = {}
    },
    getDetails() {},
  },
}
</script>

<style scoped lang="less"></style>
